using System;
using System.Collections.Generic;
using System.Linq;

namespace DIS_WEB_Client.Repositories
{
	#region using
	using DIS_WEB_Client.Models;
	using DIS_WEB_Client.Helpers;
    using DIS_WEB_Client.DIS_BUS_WS;
	#endregion
	public class LocalPromotionRepository
	{
        public LocalPromotionDTO SelectByID(int id)
        {
            try
            {
                return BusService.Instance.LocalPromotion_SelectByID(id);
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                    GlobalVariables.Logger.Error("LocalPromotion - SelectByID: " + ex.InnerException.Message.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty));
                else
                    GlobalVariables.Logger.Error("LocalPromotion - SelectByID: " + ex.Message.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty));
                return null;
            }
        }

		public List<LocalPromotionDTO> SelectByIDItem(int iditem)
		{
			try
			{
                return BusService.Instance.LocalPromotion_SelectByIDItem(iditem).ToList();
			}
			catch(Exception ex)
			{
				if (ex.InnerException != null)
				{
					GlobalVariables.Logger.Error(ex.InnerException.Message);
				}
				else
				{
					GlobalVariables.Logger.Error(ex.Message);
				}
			}
			return new List<LocalPromotionDTO>();
		}

        public LocalPromotionDTO SelectByIDItemAndIDChemistWareHouse(int iditem, int idChemistWareHouse)
        {
            try
            {
                return BusService.Instance.LocalPromotion_SelectByIDItemAndIDChemistWareHouse(iditem, idChemistWareHouse);
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    GlobalVariables.Logger.Error(ex.InnerException.Message);
                }
                else
                {
                    GlobalVariables.Logger.Error(ex.Message);
                }
            }
            return null;
        }

        public bool Insert(LocalPromotionDTO obj)
        {
            try
            {
                return BusService.Instance.LocalPromotion_Insert(obj);
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                    GlobalVariables.Logger.Error("LocalPromotion - Insert: " + ex.InnerException.Message.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty));
                else
                    GlobalVariables.Logger.Error("LocalPromotion - Insert: " + ex.Message.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty));
                return false;
            }
        }

        public bool Delete(int id)
        {
            try
            {
                return BusService.Instance.LocalPromotion_Delete(id);
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                    GlobalVariables.Logger.Error("LocalPromotion - Delete: " + ex.InnerException.Message.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty));
                else
                    GlobalVariables.Logger.Error("LocalPromotion - Delete: " + ex.Message.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty));
                return false;
            }
        }

        public bool Update(LocalPromotionDTO obj)
        {
            try
            {
                return BusService.Instance.LocalPromotion_Update(obj);
            }
            catch
            {
                return false;
            }
        }
	}
}